document.addEventListener('DOMContentLoaded', () => {
  const counters = document.querySelectorAll('.number');

  const updateCounter = (counter, target) => {
    let current = parseInt(counter.innerText, 10);
    // 确保每次的递减量至少为 1
    const increment = Math.abs(target) < 200 ? 1 : Math.abs(target / 200);

    if (current > target) {
      // 递减 current，但不要低于 target
      counter.innerText = (current - increment > target) ? Math.ceil(current - increment) : target;
      setTimeout(() => updateCounter(counter, target), 10);
    }
  };

  counters.forEach(counter => {
    const target = parseInt(counter.getAttribute('data-target'), 10);
    updateCounter(counter, target); // 初始化计数动画
  });
});



